package com.example.chat.controller;

import com.dragonsoftbravo.libs.Opr;
import com.example.chat.model.ro.LoginRO;
import com.example.chat.model.vo.LoginVO;
import com.example.chat.service.LoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Description
 * @Date 2022/11/16 22:45
 * @Author pq
 */
@RestController
@RequestMapping("/login")
@Api(value = "登录相关", tags = {"登录相关"})
public class LoginController extends BaseController {
    @Resource
    private LoginService loginService;

    @ApiOperation(value = "登录")
    @PostMapping("/login")
    public ResponseEntity<Opr<LoginVO>> login(@Validated LoginRO ro, BindingResult br){
        return this.processData(()->loginService.login(ro),br,this::processException);
    }
}
